//
//  CZStatusBottomView.swift
//  iOSWeibo10
//
//  Created by itcast on 16/5/16.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

/// 底部视图,显示3个按钮
class CZStatusBottomView: UIView {
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        preapreUI()
    }
    
    private func preapreUI() {
//        backgroundColor = UIColor.brownColor()
        
        // 添加子控件
        addSubview(retweetButton)
        addSubview(commentButton)
        addSubview(zanButton)
        
        // 添加约束
        /// 转发按钮
        retweetButton.snp_makeConstraints { (make) -> Void in
//            make.leading.equalTo(self)
//            make.top.equalTo(self)
//            make.bottom.equalTo(self)
            make.leading.top.bottom.equalTo(self)
        }
        
        /// 评论按钮
        commentButton.snp_makeConstraints { (make) -> Void in
            make.leading.equalTo(retweetButton.snp_trailing)
//            make.top.equalTo(self)
//            make.bottom.equalTo(self)
            make.top.bottom.equalTo(self)
            
            // 评论宽度等于转发宽度
            make.width.equalTo(retweetButton)
        }
        
        /// 赞
        zanButton.snp_makeConstraints { (make) -> Void in
            make.leading.equalTo(commentButton.snp_trailing)
//            make.top.equalTo(self)
//            make.trailing.equalTo(self)
//            make.bottom.equalTo(self)
            make.top.trailing.bottom.equalTo(self)
            
            // 赞的宽度等于转发宽度
            make.width.equalTo(retweetButton)
        }
    }

    //MARK: - 懒加载
    /// 转发
    private lazy var retweetButton: UIButton = UIButton(bkgImageName: "timeline_card_bottom_background", imageName: "timeline_icon_retweet", title: "转发")
//    private lazy var retweetButton: UIButton = {
//        let button = UIButton()
//        
//        // 设置
//        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background"), forState: UIControlState.Normal)
//        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background_highlighted"), forState: UIControlState.Highlighted)
//        
//        button.setImage(UIImage(named: "timeline_icon_retweet"), forState: UIControlState.Normal)
//        button.setTitle("转发", forState: UIControlState.Normal)
//        button.setTitleColor(UIColor.lightGrayColor(), forState: UIControlState.Normal)
//        
//        return button
//    }()
    
    /// 评论
    private lazy var commentButton: UIButton = UIButton(bkgImageName: "timeline_card_bottom_background", imageName: "timeline_icon_comment", title: "评论")
    
    /// 赞
    private lazy var zanButton: UIButton = UIButton(bkgImageName: "timeline_card_bottom_background", imageName: "timeline_icon_unlike", title: "赞")
}
